﻿//-----------------------------------------------------------------------
// <copyright file="UnhandledException.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics
{
    using System;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System.Runtime.Serialization;
    using System.Security;
    using System.Security.Permissions;

    /// <summary>
    /// Indicates that the <see cref="M:System.UnhandledException.InnerException"/> was unhandled.
    /// </summary>
    [Serializable]
    [Obsolete("The CodePlex.Diagnostics.UnhandledException class provides backwards compatibility only, extension methods defined within the CodePlex.Diagnostics.ExceptionExtensions class now detect unhandled exceptions automatically.", false)]
    public class UnhandledException : Exception
    {
        #region public UnhandledException()

        /// <summary>
        /// Initializes a new instance of the <see cref="UnhandledException"/> class.
        /// </summary>
        public UnhandledException()
        {
        }

        #endregion

        #region public UnhandledException(string message) : base(message)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:UnhandledException"/> class using the specified message.
        /// </summary>
        /// <param name="message">The description of the error condition.</param>
        public UnhandledException(string message) : base(message)
        {
        }

        #endregion

        #region public UnhandledException(string message, Exception innerException) : base(message, innerException)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:UnhandledException"/> class using the specified message and the inner exception.
        /// </summary>
        /// <param name="message">The description of the error condition.</param>
        /// <param name="innerException">A reference to the inner exception that is the cause of this exception.</param>
        public UnhandledException(string message, Exception innerException) : base(message, innerException)
        {
        }

        #endregion

        #region public UnhandledException(Exception inner) : base(SR.GetString(SR.UnhandledException), inner)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:UnhandledException"/> class with the specified detailed description and the specified exception. 
        /// </summary>
        /// <param name="inner">A reference to the inner exception that is the cause of this exception.</param>
        [SecurityPermission(SecurityAction.LinkDemand)]
        public UnhandledException(Exception inner) : base(SR.GetString(SR.UnhandledException), inner)
        {
        }

        #endregion

        #region protected UnhandledException(SerializationInfo info, StreamingContext context) : base(info, context)

        /// <summary>
        /// Initializes a new instance of the <see cref="T:UnhandledException"/> class using the specified serialization information and context objects.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is <c>null</c> or <see cref="P:System.Exception.HResult"/> is zero (0).</exception>
        /// <exception cref="T:System.ArgumentNullException">The info parameter is <c>null</c>.</exception>
        [SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
        protected UnhandledException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }

        #endregion

        #region public override void GetObjectData(SerializationInfo info, StreamingContext context)

        /// <summary>
        /// Sets the <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with information about the exception.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
        /// <exception cref="T:System.ArgumentNullException">The info parameter is a <c>null</c> reference (Nothing in Visual Basic). </exception>
        /// <PermissionSet>
        /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*"/>
        /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter"/>
        /// </PermissionSet>
        [SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
        }

        #endregion
    }
}
